﻿using System.Web.Routing;
using Wisdom.Core;

namespace Wisdom.Web.Mvc
{
    /// <summary>
    /// Defines a class which contains extension method for <see cref="RouteData"/>.
    /// </summary>
    public static class RouteDataExtensions
    {
        /// <summary>
        /// Controllers the name.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <returns></returns>
        public static string ControllerName(this RouteData instance)
        {
            Guard.IsNotNull(instance, "instance");

            return instance.GetRequiredString("controller");
        }

        /// <summary>
        /// Actions the name.
        /// </summary>
        /// <param name="instance">The instance.</param>
        /// <returns></returns>
        public static string ActionName(this RouteData instance)
        {
            Guard.IsNotNull(instance, "instance");

            return instance.GetRequiredString("action");
        }
    }
}
